package com.csgc.camera.http

import android.util.Log


import com.moczul.ok2curl.CurlInterceptor
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import java.util.concurrent.TimeUnit


class OkHttpManager private constructor(){

    var okHttpClient: OkHttpClient
    init {
        val builder = OkHttpClient().newBuilder()
            .connectTimeout(60, TimeUnit.SECONDS)
            .readTimeout(60, TimeUnit.SECONDS)
            .writeTimeout(60, TimeUnit.SECONDS)
//            .addInterceptor(TokenPastInterceptor())


//        if (BuildConfig.DEBUG){
//            builder.apply {
//                val logging = HttpLoggingInterceptor()
//                logging.setLevel(HttpLoggingInterceptor.Level.BODY)
//                addInterceptor(logging)
//
//                addInterceptor(CurlInterceptor(logger = object :com.moczul.ok2curl.logger.Logger{
//                    override fun log(message: String) {
//                        Log.v("Ok2Curl", message)
//                    }
//                }))
//
//            }
//        }

        okHttpClient = builder.build()
    }

    companion object{
        fun getInstance(): OkHttpManager {
            return Holder.instance
        }

    }

    private object Holder{
        val instance = OkHttpManager()
    }
}